<style lang="scss" scoped>
.dialog {
  .shade {
    width: 100%;
    height: 100%;
    position: fixed;
    top: 0;
    left: 0;
    background: #000;
    opacity: 0.2;
    overflow: hidden;
    z-index: 1000;
    color: #fff;
  }
  .dialog_body {
    position: fixed;
    top: 50%;
    left: 50%;
    min-width: 200px;
    min-height: 400px;
    max-height: 80%;
    transform: translate(-50%, -50%);
    -webkit-transform: translate(-50%, -50%);

    width: 90%;
    overflow: hidden;
    z-index: 2000;
    background: #ffffff;
    padding-top: 30px;
    padding-left: 25px;
    padding-right: 25px;
    padding-bottom: 36px;
    border-radius: 10px;
    text-align: center;
    .title {
      span {
        font-size: 18px;
        color: #1f88fe;
        text-align: center;
      }
    }
    .icon {
      height: 25px;
      .iconfont {
        float: right;
        color: #ffffff;
        font-size: 16px;
        background-color: #1f88fe;
        border-radius: 50%;
        line-height: 22px;
        width: 22px;
        height: 22px;
        position: relative;
        bottom: 25px;
        text-align: center;
      }
    }
    .subhead {
      margin-top: 10px;
      font-size: 16px;
      color: #1f88fe;
      text-align: center;
      margin-bottom: 25px;
    }
    .short-line {
      width: 100%;
      height: 1px;
      background-color: #e0e0e0;
    }
    .content {
      margin-top: 14px;
      font-size: 14px;
      color: #666666;
      line-height: 22px;
      margin-bottom: 30px;
      text-align: left;
    }
    .buttongroup {
      display: flex;
      width: 85%;
      justify-content: space-between;
      position: absolute;
      bottom: 30px;
      .button {
        font-size: 16px;
        padding-left: 15px;
        padding-right: 15px;
      }
      .confirm {
        margin-right: 10px;
        background-color: #1f88fe;
        color: #ffffff;
        border-radius: 4px;
        height: 40px;
        line-height: 40px;
      }
      .cancel {
        margin-left: 10px;
        color: #1f88fe;
        border-radius: 4px;
        height: 40px;
        line-height: 40px;
      }
    }
  }
}
</style>

<template>
  <div v-if="visiable" class="dialog">
    <div class="shade">
    </div>
    <div class="dialog_body">
      <div class="title">
        <span>{{title}}</span>
      </div>
      <div v-if="closable" class="icon">
        <div class="iconfont icon-close" @click="close"></div>
      </div>
      <div v-if="subhead" class="subhead">{{subhead}}</div>
      <div class="short-line"></div>
      <div class="content">
        <slot name="content">{{content}}</slot>
      </div>
      <div class="buttongroup">
        <div class="button cancel" @click="cancleMethod">{{cancel || '取消'}}</div>
        <div class="button confirm" @click="confirmMethod">{{confirm || '确认'}}</div>
      </div>
    </div>
  </div>
</template>
<script>
export default {
  data () {
    return {
      visiable: false
    }
  },
  computed: {
  },
  props: {
    title: { type: String, default: '提示' },
    cancel: { type: String, default: '取消' },
    confirm: { type: String, default: '确定' },
    content: { type: String, default: '暂无内容' },
    closable: { type: Boolean, default: true },
    subhead: String
  },
  methods: {
    cancleMethod () {
      this.$emit('cancle')
      if (this.closable) {
        this.close()
      }
    },
    close () {
      this.$emit('close')
      this.visiable = false
    },
    open () {
      this.visiable = true
    },
    confirmMethod () {
      this.$emit('confirm')
    }
  }
}
</script>
